<template>
    <div>
        <h1>订单列表</h1>
        <template>
            <el-table
                    :data="tableData"
                    style="width: 100%">
                <el-table-column
                        prop="id"
                        label="序号"
                        width="300">
                </el-table-column>
                <el-table-column
                        prop="name"
                        label="姓名"
                        width="300">
                </el-table-column>
                <el-table-column
                        prop="create_date"
                        width="300"
                        label="创建时间">
                </el-table-column>
                <el-table-column
                        prop="customer_id"
                        width="300"
                        label="外键">
                </el-table-column>
            </el-table>
        </template>
        <!--<el-button @click="pubData">点击发布消息</el-button>-->
        <child_1></child_1>
        <child_2></child_2>
    </div>
</template>

<script>
    import PubSub from 'pubsub-js'
    import child1 from '../components/child1'
    import child2 from '../components/child2'
    import Child_1 from "./child1";
    import Child_2 from "./child2";

    export default {
        name: "orders",
        components: {Child_2, Child_1},
        comments: {
            child1,
            child2
        },
        data() {
            return {
                tableData: [],//订单数据
            }
        },

        created() {
            this.GetOrdersData();
        },

        // filters: {
        //     FormData(arg) {
        //         var list = arg.split("T");
        //         return list[0];
        //     }
        // },

        methods: {
            pubData() {
                //发布消息
                console.log("******************orders 组件中数据发布***********************")
                PubSub.publish("dataCome", this.tableData)
            },

            GetOrdersData() {
                debugger
                var that = this
                this.$axios.post('http://127.0.0.1:80/sales/listorders/').then(function (response) {
                    console.log("-----------------------------------")
                    console.log(response)
                    that.tableData = response.data.retlist;
                    that.ProcessData();

                }).catch(function (error) {
                    console.log(error);
                });
            },

            FormData(arg) {
                var list = arg.split("T");
                return list[0];
            },

            ProcessData() {
                this.tableData.map((value) => {
                    value.create_date = this.FormData(value.create_date)
                    console.log(value)
                })
            }
        }
    }
</script>

<style scoped>

</style>